package lambda.function;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Function;

public class FunctionTest {

    public static void main(String[] args) {
        Function<Date, String> f1 = FunctionTest::convert;
        System.out.println(f1.apply(new Date()));
        Function<Date, String> f2 = (Date date) ->
                new SimpleDateFormat("yyyyMMdd").format(date);
        System.out.println(f2.apply(new Date()));
        Function<Date, String> f3 = (Date date) ->{
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            return sdf.format(date);
        };
        System.out.println(f3.apply(new Date()));
    }

    static String convert(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(date);
    }
}
